//
//  ST_ChatTimeintervalCell.swift
//  mewpoo
//
//  Created by DouLei on 2018/11/7.
//  Copyright © 2018 DouLei. All rights reserved.
//

import UIKit
import SwifterSwift
import SnapKit

class ST_ChatTimeintervalCell: UITableViewCell {

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.contentView.backgroundColor = Color.white
        self.contentView.addSubview(time_label)
        time_label.snp.makeConstraints { (make) in
            make.center.equalTo(self.contentView)
            make.height.equalTo(18)
            make.width.equalTo(20)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    var message:ST_DTChatMessage! {
        didSet{
            
            var text = ""
            
            if message.cellStyle == .timeinterval{
                text = message.timeintervalStr
            }else{
                text = message.recallStr
            }
            
            let width = text.width(withConstrainedHeight: 40, font: UIFont.systemFont(ofSize: 10)) + 5
            
            time_label.text = text
            time_label.snp.updateConstraints { (make) in
                make.width.equalTo(width)
            }
        }
    }
    
    
    lazy var time_label:UILabel = {
        
        let control = UILabel()
        control.textColor = Color.init(hex: 0x888B9D)
        control.font = UIFont.systemFont(ofSize: 10)
        control.textAlignment = .center
        control.backgroundColor = Color.init(hex: 0xF2F4F7)
        control.cornerRadius = 6
        return control
    }()
}
